{
Traviesadora beta 0.2.0.13.33 (30.11.2008)
LastMod: 12.12.2008 by Prof1983

Copyright 2008, travieorama@googlemail.com

This file is part of the taviesadora project

taviesadora is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

taviesadora is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.
}
unit debugwin;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, InetCommunication, ComCtrls;

type
  TFrmDebug = class(TForm)
    RichEdit1: TRichEdit;
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
  private
    JabberObj: TInetCom;
    procedure SetJabber(const Value: TInetCom);
  public
    procedure Clear();
    procedure NewString(t: string; tx: Boolean);
    property Jabber1: TInetCom read JabberObj write SetJabber; 
  end;

var
  FrmDebug: TFrmDebug;

implementation

uses // TODO: Move up...
  Jabber, JabberHelper;

{$R *.dfm}

{ TForm3 }

procedure TFrmDebug.Clear();
begin
  RichEdit1.Clear;
end;

procedure TFrmDebug.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  if jabberObj is TJabber then
    (jabberObj as TJAbber).SetDebugFrm(nil)
  else if jabberObj is TJabberHelper then
    (jabberObj as TJabberHelper).SetDebugFrm(nil)
end;

procedure TFrmDebug.NewString(t: string; tx: boolean);
begin
  if tx then begin
    RichEdit1.SelAttributes.Color := clred;
    t := 'TX: '+t;
  end else begin
    t := 'RX: '+t;
    RichEdit1.SelAttributes.Color := clblue;
  end;
  RichEdit1.Lines.add(t);
  RichEdit1.Lines.add('');
end;

procedure TFrmDebug.SetJabber(const Value: TInetCom);
begin
  Self.JabberObj := Value;
  if Value is TJabber then
    (JabberObj as TJabber).SetDebugFrm(Self)
  else if (Value is TJabberHelper) then
    (JabberObj as TJabberHelper).SetDebugFrm(Self);
end;

end.
